<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>切换Eportal版本</title>

<link rel="stylesheet" type="text/css" href="http://adminlte.tbpdd.top/css/page.css" />
<link rel="stylesheet" type="text/css" href="http://adminlte.tbpdd.top/buttons/buttons.css" />

</head>

<body>

<div id="buttonContainer" style="width: 328px;">


    <a href="javascript:void(0);" class="button small orange">选择查看版本：</a>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>

    <a href="?version=4.1.3" class="button big blue" target="_self">Eportal  4.1.3  版本</a>
    <a href="?version=4.2.1" class="button big green" target="_self">Eportal  4.2.1  版本</a>
	<a href="?version=4.3" class="button big orange" target="_self">Eportal  4.3.0  版本</a>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>


</div>

<div id="footer">
	<div class="tri"></div>
	<h1>当前版本 <a href='/eportal'><?php echo end(explode('/',realpath('/drcom/http/php/eportal')));?></a></h1>
    <p class="note"><?php echo end(explode(PHP_EOL,trim(@file_get_contents('version.log')))) ?></p>
</div>


</body>
</html>

<?php 

if(isset($_GET['version'])){
	$version = $_GET['version'];
	if("eportal$version"){
        date_default_timezone_set('PRC');
        $log = date('Y-m-d H:i:s')." : ".$_SERVER["REMOTE_ADDR"]." -> ".$version.PHP_EOL;
        file_put_contents('version.log',$log,8);
		$cmd = "unlink eportal && ln -s eportal$version eportal";
		shell_exec($cmd);\
		copy('/tmp/php_restart', '/dev/shm/php_restart');
		$cmd = "S3348" . "\t/dev/shm/php_restart";
		$result = dren_SendCommandEx($cmd);

		Header("Location: /eportal");
	}
}
